package cn.daniellee.plugin.vs.listener;

import cn.daniellee.plugin.vs.core.VisitorCore;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;

import java.util.LinkedList;

public class PlayerListener implements Listener {

	@EventHandler
	public void onPlayerMove(PlayerMoveEvent e) {
		Player player = e.getPlayer();
        LinkedList<Location> record = VisitorCore.recording.get(player.getName());
		if (record != null) {
		    Location location = player.getLocation();
            Bukkit.broadcastMessage("Data: " + location.getX() + "," + location.getY() + "," + location.getZ() + "," + location.getYaw() + "," + location.getPitch());
		    record.add(location);
        }
	}

	@EventHandler
	public void onPlayerTeleport(PlayerTeleportEvent e) {

	}

	@EventHandler
	public void onPlayerQuit(PlayerQuitEvent e) {

	}

	@EventHandler
	public void onPlayerDeath(PlayerDeathEvent e) {

	}

}
